package com.kaifamiao.dispatch;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.logging.Logger;

@WebServlet( "/inner" )
public class InnerServlet extends HttpServlet {

    private Logger logger = Logger.getLogger( this.getClass().getName() ) ;

    @Override
    protected void service(HttpServletRequest request , HttpServletResponse response)
            throws ServletException, IOException {
        logger.info( "从请求对象中获取属性:" + request.getAttribute( "outer" ) );
        logger.info( "向请求对象中设置属性" );
        request.setAttribute( "inner" , "被包含的servlet" );

        PrintWriter out = response.getWriter();
        logger.info( "向响应对象输出数据" );
        out.println( "<div style='border: 1px solid blue; margin: 5px ;'>inner servlet</div>" );
    }
}
